const { babel } = require('@rollup/plugin-babel');
const istanbul = require('rollup-plugin-istanbul');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
// Karma configuration
// Generated on Mon Dec 28 2020 09:51:04 GMT-0300 (GMT-03:00)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '../..',

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: [
      'jasmine',
    ],

    plugins: [
      'karma-jasmine',
      'karma-rollup-preprocessor',
      'karma-chrome-launcher',
      'karma-firefox-launcher',
      'karma-coverage-istanbul-reporter'
    ],

    files: [
      {
        pattern: 'js/tests/unit/**/!(jquery).spec.js',
      }
    ],
    
    preprocessors: {
      'js/tests/unit/**/*.spec.js': ['rollup']
    },

    rollupPreprocessor: {
      plugins: [
        istanbul({
          exclude: [
          'node_modules/**',
          'js/tests/unit/**/*.spec.js',
          'js/tests/helpers/**/*.js'
          ]
        }),
        babel({
          exclude: 'node_modules/**',
          babelHelpers: 'inline'
        }),
        nodeResolve()
      ],
      output: {
        format: 'iife',
        name: 'flowcssTest',
        sourcemap: 'inline'
      }
    },

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['dots'],

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome', 'Firefox'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
};
